<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
<link
	href="${pageContext.request.contextPath}/resources/MUI/css/mui.indexedlist.css"
	rel="stylesheet" />
<script
	src="${pageContext.request.contextPath}/resources/MUI/js/mui.indexedlist.js"></script>
</head>
<style type="text/css">
.mui-indexed-list {
	height: 100% !important;
}

.mui-search input[type=search] {
	padding-left: 30px;
	width: 65%;
	text-align: left;
}

#list, .mui-indexed-list-search {
	border: 0;
}
</style>
<form class="mui-input-group">
	<div class="mui-input-row">
		<label>ID:</label> <input type="text" class="caseNo" name="caseNo"
			placeholder="请输入储物柜ID"> <input type="hidden" class="id"
			name="id"> <span class="must">*</span>
	</div>

	<div class="mui-input-row fileId">
		<label>被选中:</label> <a style="line-height: 40px;"></a> <input
			type="hidden" name="fileId"> <span class="must">*</span>
	</div>

	<!-- 广告  -->
	<div class="mui-content">
		<div id='list' class="mui-indexed-list">
			<div class="mui-indexed-list-search mui-input-row mui-search">
				<label>选择广告:</label> <input type="search"
					class="mui-input-clear mui-indexed-list-search-input"
					placeholder="搜索广告"> <span class="must">*</span>
			</div>
			<div class="mui-indexed-list-bar" style="display: none;"></div>
			<div class="mui-indexed-list-alert"></div>
			<div class="mui-indexed-list-inner" id='done'>
				<div class="mui-indexed-list-empty-alert">没有数据</div>
				<ul class="mui-table-view">
					<c:forEach items="${list }" var="list">
						<c:if test="${list.flag == 1 }">
							<li
								class="mui-table-view-cell mui-indexed-list-item mui-radio mui-left">
								<input type="radio" name="demo" value="${list.fileId }" checked />${list.name }</li>
						</c:if>
						<c:if test="${list.flag != 1 }">
							<li
								class="mui-table-view-cell mui-indexed-list-item mui-radio mui-left">
								<input type="radio" name="demo" value="${list.fileId }" />${list.name }</li>
						</c:if>
					</c:forEach>
				</ul>
			</div>
		</div>
	</div>
	<div class="mui-input-row">
		<label>描述:</label> <input type="text" class="des" name="des"
			placeholder="请输入位置等描述">
	</div>
	<div class="mui-button-row">
		<a type="button" class="mui-btn mui-btn-primary submit">提交</a>
	</div>
</form>
<script type="text/javascript">
    	mui('#offCanvasContentScroll').scroll().scrollTo(0,0);
    
    	$(".mui-title").html("修改广告");
    	
		var publish = sessionStorage.getItem('publish');
		publish = JSON.parse(publish);
		$(".caseNo").val(publish.caseNo);
		$(".id").val(publish.id);
		$(".des").val(publish.des);
		$(".fileId a").html(publish.adName);
		$(".fileId input").val($("input[type='radio']:checked").val());
		
		var list = document.getElementById('list');
		window.indexedList = new mui.IndexedList(list);
		
		$(".mui-indexed-list-inner").hide();
		$("#list").on("touchstart","input",function(){
			$(".mui-indexed-list-inner").show();
		})
		
		
		mui(".mui-indexed-list-inner").on("tap",".mui-table-view li",function(){
			$(".mui-indexed-list-inner").hide();
			$(".fileId input").val($(this).children("input").val())
			$(".fileId a").html($(this).text());
		})
		
		/* ---------------------------- 广告 ---------------------------- */
		
	   $(".submit").on("touchstart",function(){
			var param = $("form").serialize();
	    	let caseNo = $(".caseNo").val();

	    	if(caseNo != ""){
				$.post("/publish/updateAdvertise",param,function(res){
					
					if(res.success){
						mui.toast("修改成功");
						history.back();
			    	}else{
			    		mui.toast(res.message);
			    	}
					
				})
	    	}else{
	    		mui.toast("带 "+'<span style="color:red;">*</span> 为必填项');
	    	}
	   })
	   
	</script>
</html>